package Cliente;

/*
 * EnviarTareaForm.java
 *
 * Created on 16-may-2009, 13:11:07
 */

/**
 *Clase que crea una ventana para enviar un mensaje a un usuario.
 * 
 * @author Juanma
 */
public class EnviarTareaForm extends javax.swing.JFrame {
    ClienteNTask sender;  //Objeto del usuario que env&iacute;a el mensaje
    
    /** Constructor de la clase
     *
     * @param ntCli Objeto del usuario que env&iacute;a el mensaje
     */
    public EnviarTareaForm(ClienteNTask ntCli) {
        sender = ntCli;
       
        initComponents();

        //Rellenar el ComboBox de los estados
        cb_Estado.setEditable(false);
        cb_Estado.removeAllItems();
        cb_Estado.addItem("Creada");
        cb_Estado.addItem("Finalizada");
        cb_Estado.addItem("Desarrollo");
        cb_Estado.addItem("Espera");
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        b_EnviarTarea = new javax.swing.JButton();
        tf_Destino = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        ta_Mensaje = new javax.swing.JTextArea();
        l_enviara = new javax.swing.JLabel();
        bt_Salir = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        tf_Responsable = new javax.swing.JTextField();
        tf_Creador = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        tf_FechaInicio = new javax.swing.JTextField();
        tf_FechaFin = new javax.swing.JTextField();
        tf_Titulo = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        cb_Estado = new javax.swing.JComboBox();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Enviar tarea");
        setAlwaysOnTop(true);

        b_EnviarTarea.setText("Enviar");
        b_EnviarTarea.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                b_EnviarTareaActionPerformed(evt);
            }
        });

        tf_Destino.setName("tf_Destino"); // NOI18N

        ta_Mensaje.setColumns(20);
        ta_Mensaje.setRows(5);
        ta_Mensaje.setName("ta_mensaje"); // NOI18N
        jScrollPane1.setViewportView(ta_Mensaje);

        l_enviara.setText("Enviar a:");

        bt_Salir.setText("Salir");
        bt_Salir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt_SalirActionPerformed(evt);
            }
        });

        jLabel1.setText("Creador:");

        jLabel2.setText("Responsable:");

        jLabel3.setText("Mensaje:");

        jLabel4.setText("Fecha de inicio:");

        jLabel5.setText("Fecha de fin:");

        jLabel6.setText("Título:");

        jLabel7.setText("Estado:");

        cb_Estado.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 514, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(bt_Salir, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(b_EnviarTarea, javax.swing.GroupLayout.Alignment.TRAILING)))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel4)
                            .addComponent(jLabel5)
                            .addComponent(jLabel6)
                            .addComponent(jLabel2)
                            .addComponent(jLabel1)
                            .addComponent(l_enviara)
                            .addComponent(jLabel3)
                            .addComponent(jLabel7))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(tf_Destino, javax.swing.GroupLayout.DEFAULT_SIZE, 446, Short.MAX_VALUE)
                            .addComponent(tf_Creador, javax.swing.GroupLayout.DEFAULT_SIZE, 446, Short.MAX_VALUE)
                            .addComponent(tf_Responsable, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 446, Short.MAX_VALUE)
                            .addComponent(tf_Titulo, javax.swing.GroupLayout.DEFAULT_SIZE, 446, Short.MAX_VALUE)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(tf_FechaFin)
                                .addComponent(tf_FechaInicio, javax.swing.GroupLayout.PREFERRED_SIZE, 195, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(cb_Estado, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(tf_Destino, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(12, 12, 12)
                        .addComponent(tf_Creador, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(12, 12, 12)
                        .addComponent(tf_Responsable, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(l_enviara)
                        .addGap(22, 22, 22)
                        .addComponent(jLabel1)
                        .addGap(22, 22, 22)
                        .addComponent(jLabel2)))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(tf_FechaInicio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(tf_FechaFin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(16, 16, 16)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(tf_Titulo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(cb_Estado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(b_EnviarTarea)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(bt_Salir)))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     * Ejecutado al pulsar el bot&oacute;n "Enviar". Llama al m&eacute;todo del
     * servidor "enviarTarea". Al final cierra la ventana.
     * 
     * @param evt
     */
    private void b_EnviarTareaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_b_EnviarTareaActionPerformed
        // TODO add your handling code here:      

        //Invocamos al método de la ventana principal para para enviar la tarea
        sender.enviarTarea(cb_Estado.getSelectedItem().toString(),
                tf_FechaInicio.getText(), tf_FechaFin.getText(),
                tf_Titulo.getText(), ta_Mensaje.getText(), tf_Creador.getText(),
                tf_Responsable.getText(),tf_Destino.getText());

        //Salir de la ventana
        this.dispose();
    }//GEN-LAST:event_b_EnviarTareaActionPerformed

    /**
     * Ejecutado al pulsar el bot&oacute;n "Salir".
     * @param evt
     */
    private void bt_SalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_SalirActionPerformed
        // TODO add your handling code here:
        this.dispose();
    }//GEN-LAST:event_bt_SalirActionPerformed

   
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton b_EnviarTarea;
    private javax.swing.JButton bt_Salir;
    private javax.swing.JComboBox cb_Estado;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel l_enviara;
    private javax.swing.JTextArea ta_Mensaje;
    private javax.swing.JTextField tf_Creador;
    private javax.swing.JTextField tf_Destino;
    private javax.swing.JTextField tf_FechaFin;
    private javax.swing.JTextField tf_FechaInicio;
    private javax.swing.JTextField tf_Responsable;
    private javax.swing.JTextField tf_Titulo;
    // End of variables declaration//GEN-END:variables

}
